class Solution {
public:

    int Cdiff(string& A, int l, int r)
    {
        while(l >= 0 && r < A.size() && A[l] == A[r]) l--,r++;
        return r - l - 1;
    }
    int getLongestPalindrome(string A) 
    {
        int ans = 0;
        for(int i = 0; i < A.size(); i++)
            ans = max(ans, max(Cdiff(A, i, i), Cdiff(A, i, i + 1)));
        return ans;
    }
};
